home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 80 / CD Actual 80 Julio-Agosto 2003.iso / Linux / LinuxGazette / lg / issue17 / source / RCThreads.sl < prev    next >
Encoding:
Text File  |  2002-08-14  |  601 b   |  28 lines

  1.  
  2. /*
  3.  * threads(): wrap threads around a cylinder 
  4.  */
  5. displacement 
  6. RCThreads ( 
  7.    float   Km   =  .1,
  8.       frequency = 5.0,
  9.       phase     =  .0,
  10.       offset    =  .0,
  11.       dampzone  =  .05 )
  12. {
  13.    float magnitude;
  14.  
  15.    /* Calculate the undamped displacement */
  16.    magnitude = (sin( PI*2*(t*frequency + s + phase))+offset) * Km;
  17.  
  18.    /* Damp the displacement to 0 at each end */
  19.    if( t > (1-dampzone)) 
  20.       magnitude *= (1.0-t) / dampzone;
  21.    else if( t < dampzone )
  22.       magnitude *= t / dampzone;
  23.  
  24.    /* Do the displacement */
  25.    P += normalize(N) * magnitude;
  26.    N = calculatenormal(P);
  27. }
  28.